import {defineStore} from 'pinia'
import { computed, ref } from 'vue'
// 推荐大家仓库命名  userXXXStore
export const useCounterStore = defineStore('counter', () => {
  // state
  const count = ref(100)
  // getters
  const doubleCount = computed(() => count.value *2)
  // mutations
  const update = () => count.value++
  // actions
  const asyncUpdate = () => {
    setTimeout(() => {
      count.value+=10
    }, 2000)
  }
  return {
    count,
    doubleCount, 
    update,
    asyncUpdate
  }
})